import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';

import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Subject } from 'rxjs/Subject';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/publishReplay';
//import 'rxjs/add/operator/refCount';

import { HttpUtils } from '../utils/http-utils';

@Injectable()
export class RecentlyDocumentsService {

  constructor(private http: Http) { }

  getDocuments () {
    return this.http.get('api/documents/recently')
      .publishReplay(1)
      .refCount()
      .map(HttpUtils.extractData)
      .catch(HttpUtils.handleError)
  }

}
